feat(slider): implement infinity dragging using PointerLock API#206
Open
claygeo wants to merge 1 commit intopascalorg:mainfrom
Open
feat(slider): implement infinity dragging using PointerLock API#206claygeo wants to merge 1 commit intopascalorg:mainfrom
claygeo wants to merge 1 commit intopascalorg:mainfrom
Conversation
Slider controls now use the PointerLock API for drag interactions, allowing users to drag values past the screen edge without the cursor stopping. This matches the behavior of sliders in Unity3D and other professional 3D editors. When a user drags a slider label, the cursor locks and hides while movementX accumulates the total drag distance. Releasing or pressing Escape exits the lock cleanly with proper undo/redo tracking. Falls back to setPointerCapture for browsers that don't support PointerLock. Adapts the existing pattern from first-person-controls.tsx. Closes pascalorg#204
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #204
Saw this was on your radar @Aymericr — figured I'd take a crack at it since the PointerLock pattern already exists in
first-person-controls.tsx.Slider controls now use the Pointer Lock API for drag interactions. When dragging a slider label, the cursor locks and movement continues infinitely past the screen edge, matching the behavior in Unity3D and other professional 3D editors.
Changes
packages/editor/src/components/ui/controls/slider-control.tsx— 1 file, ~40 lines changedsetPointerCapture+e.clientXrequestPointerLock+e.movementXHow it works
requestPointerLock()locks the cursor and hides ite.movementX(relative delta, not viewport-bound)document.exitPointerLock(), cursor reappears at original positionpointerlockchangelistener cleans up drag state gracefullyEdge cases handled
setPointerCapture(existing behavior)pointerlockchangelistener catches this, commits the value, resumes undo trackingReference
Adapted from the existing PointerLock usage in
first-person-controls.tsx(lines 50-64) which uses the same API for camera mouse look.Test plan